Cuestionario Ampliado del Censo de Población y Vivienda 2010

El cuestionario ampliado se guarda en un un archivo _Base2020.RData.

data <- read_sav("~/Población 2010/Cuestionario Ampliado_2010_Persona.sav")

save(data, 
      file = paste0(here::here(),"/Bases/Censo_Personas_2010.RData"))

Se seleccionan las variables que se desean conservar para la realización de este documento y se guarda en un archivo _Base2020.RData para practicidad del manejo de datos.

Posibles variables que se pueden contemplar en la migración reciente

  • EDAD
  • SEXO
  • AFRODES
  • HLENGUA 
  • QDIALECT_C
  • PERETN 
  • NIVACAD
  • ALFABET
  • ESTCON 
  • CONACT 
  • HIJOS_NAC_VIVOS
load(paste0(here::here(),"/Bases/Censo_Personas_2010.RData"))

mydata <- data %>%
           select(ENT, NOM_ENT, MUN, NOM_MUN, ENT_MUN, 
                  LNACEDO_C, LNACPAIS_C,
                  RES05EDO_C, RES05PAI_C, MUN05OTR_C,
                  LTRABPAI_C, LTRABMUN_C, ENT_MUN_TRABAJO,
                  EDAD, SEXO, HLENGUA, QDIALECT_C, LI_INALI, PERETN, NIVACAD, ALFABET, 
                  ESTCON, CONACT,  OCUACTIV_C, HORTRA, INGTRMEN, SITTRA, FACTOR, ESTRATO, UPM) %>%
            rename("CVE_ENT" = "ENT",
                   "CVE_MUN" = "ENT_MUN",
                   "MUN_TRAB" = "LTRABMUN_C",
                   "CVE_MUN_TRABAJO" = "ENT_MUN_TRABAJO") %>%
             mutate(CVE_ENT = str_pad(.$CVE_ENT, width = 3, side = c("left"), pad = "0"),
                    CVE_MUN = str_pad(.$CVE_MUN, width = 6, side = c("left"), pad = "0")) %>%
              mutate(CVE_MUN_RES = paste0(.$RES05EDO_C, MUN05OTR_C))

Zonas Metropolitanas 2020

Se anexa la base de datos de las Zonas Metropolitanas 2020 a la base orginal

ZM_2020 <- read.xlsx(paste0(here::here(), "/Bases/Municipio/ZM_2020.xlsx"), 
                      startRow = 7, 
                       skipEmptyRows = TRUE) %>%
            select(CVE_ZM, NOM_ZM, CVE_ENT, NOM_ENT, CVE_MUN, NOM_MUN, MC, CF) %>%
             mutate(CVE_ENT = stringr::str_pad(.$CVE_ENT, width = 3, side = c("left"), pad = "0"),
                    CVE_MUN = stringr::str_pad(.$CVE_MUN, width = 6, side = c("left"), pad = "0"))

Se asignan las claves de las zonas metropolitanas de acuerdo a las diferentes variables de interes:

  • Residencia hace 5 años

  • Laboral

mydata <- mydata %>%
           # Zonas Metropolitanas por residenicia
           left_join(., ZM_2020 %>% select(-c(CVE_ENT, NOM_ENT, NOM_MUN)), by = c("CVE_MUN")) %>%
            # Zonas Metropolitanas en el lugar de residencia hace 5 años
            left_join(., ZM_2020 %>% select(-c(CVE_ENT, NOM_ENT, NOM_MUN)) %>% 
                           rename("CVE_ZM_RES" = "CVE_ZM",
                                  "ZM_RES" = "NOM_ZM"), by = c("CVE_MUN_RES" = "CVE_MUN")) %>%
             # Zonas Metropolitanas en el lugar de trabajo
             left_join(., ZM_2020 %>% select(-c(CVE_ENT, NOM_ENT, NOM_MUN)) %>% 
                           rename("CVE_ZM_TRABAJO" = "CVE_ZM",
                                  "ZM_TRABAJO" = "NOM_ZM"), by = c("CVE_MUN_TRABAJO" = "CVE_MUN")) 

save(mydata, file = paste0(here::here(), "/Bases/06_Migracion por Zonas Metropolitanas_2010_Base2020.RData"))          

✔️A partir de aquí se pueden correr los códidos 👇.
Se carga el archivo Migracion por Zonas Metropolitanas_2010_Base2020.RData.

load(file = paste0(here::here(), "/Bases/06_Migracion por Zonas Metropolitanas_2010_Base2020.RData"))  

# Para fines prácticos se genera un ponderador de uno 
mydata <- mydata %>%
           select(CVE_ENT, NOM_ENT, CVE_MUN, NOM_MUN, RES05EDO_C, CVE_MUN_RES, 
                  CVE_ZM, NOM_ZM, CVE_ZM_RES, ZM_RES,
                  EDAD, FACTOR, ESTRATO, UPM) %>%
            mutate(M = 1)

# Se vuelve a cargar la base de datos para fines practicos
ZM_2020 <- read.xlsx(paste0(here::here(), "/Bases/Municipio/ZM_2020.xlsx"), 
                      startRow = 7, 
                       skipEmptyRows = TRUE) %>%
            select(CVE_ZM, NOM_ZM, CVE_ENT, NOM_ENT, CVE_MUN, NOM_MUN, MC, CF) %>%
             mutate(CVE_ENT = stringr::str_pad(.$CVE_ENT, width = 3, side = c("left"), pad = "0"),
                    CVE_MUN = stringr::str_pad(.$CVE_MUN, width = 6, side = c("left"), pad = "0"))

Entidades y Municipios

Se genera un vector con el nombre de las entidades llamado estados para facilitar los filtros en el documento.
Se genera un vector con las abreviaturas de las entidades llamado ent para fines prácticos.
Se genera un vector con las claves de los municipios.

# Claves de los estados
estados <- sjlabelled::get_labels(mydata$CVE_ENT)

nom_estados <- c( "Aguascalientes", "Baja California" ,"Baja California Sur", "Campeche", "Coahuila de Zaragoza", "Colima", 
                  "Chiapas", "Chihuahua", "Ciudad de México", "Durango", "Guanajuato", "Guerrero", "Hidalgo", "Jalisco",        
                  "México", "Michoacán de Ocampo", "Morelos", "Nayarit", "Nuevo León", "Oaxaca", "Puebla", "Querétaro", 
                  "Quintana Roo", "San Luis Potosí", "Sinaloa", "Sonora", "Tabasco", "Tamaulipas", "Tlaxcala", 
                  "Veracruz de Ignacio de la Llave", "Yucatán", "Zacatecas")

est <- c("AGS", "BC", "BCS", "CAMP", "COAH", "COL", "CHIS", "CHIH", "CDMX", "DGO", "GTO", "GRO", "HGO",
         "JAL", "MEX", "MICH", "MOR", "NAY", "NL", "OAX", "PUE", "QRO", "QROO", "SLP","SIN","SON", "TAB", 
         "TAMS", "TLX", "VER", "YUC", "ZAC")

# Claves de los municipios
MUN <- readRDS(paste0(here::here(), "/Bases/municipios_2010.RDS"))
nom_municipios <- sjlabelled::get_labels(MUN$NOM_MUN) %>% as.factor()
municipios <- sjlabelled::get_labels(MUN$CVE_MUN) %>% as.factor()
#saveRDS(MUN, file = paste0(here::here(), "/Bases/municipios_2010_Base2020.RDS"))

# Claves de las zonas metropolitanas
zm <- sjlabelled::get_labels(mydata$CVE_ZM)[-2]
nom_zm <- sjlabelled::get_labels(mydata$NOM_ZM)[-2]

Migración reciente

Migración interna

Matrices

Se utiliza la paquetería survey para poder trabajar con la muestra del cuestionario ampliado, en la cual se selecciona a la población de 5 años y más.

options(survey.lonely.psu = "adjust")

MC <- mydata %>%
       select(CVE_ENT, CVE_MUN, RES05EDO_C, CVE_MUN_RES, CVE_ZM, CVE_ZM_RES, M, EDAD, FACTOR, ESTRATO, UPM) %>%
        # Se genera una indicadora de zm 
        mutate(I_ZM_2020 = ifelse(is.na(.$CVE_ZM), '0', '1'),
               I_RES5A_ZM_2020 = ifelse(is.na(.$CVE_ZM_RES), '0', '1')) %>%
        # Se clasifican a los migrantes internos 
        mutate(I_ZM = case_when(.$CVE_MUN == .$CVE_MUN_RES ~ 'Pertenecen a la Zona Metropolitana', #Residentes
                                .$CVE_MUN != .$CVE_MUN_RES & .$I_ZM_2020 %in% '1' & .$I_RES5A_ZM_2020 %in% '1' & .$CVE_ZM == .$CVE_ZM_RES ~ "Pertenecen a la Zona Metropolitana", #Migrantes que residen en la misma zona metropolitana
                                .$CVE_MUN != .$CVE_MUN_RES & .$I_ZM_2020 %in% '1' & .$I_RES5A_ZM_2020 %in% '1' & .$CVE_ZM != .$CVE_ZM_RES ~ 'No pertenecen a la Zona Metropolitana', #Migrantes que residen en otra zona metropolitana
                                .$CVE_MUN != .$CVE_MUN_RES & .$I_ZM_2020 %in% '1' & .$I_RES5A_ZM_2020 %in% '0' ~ 'No pertenecen a la Zona Metropolitana', #Migrantes que residian fuera de la zona metropolitana
                                .$CVE_MUN != .$CVE_MUN_RES & .$I_ZM_2020 %in% '0' & .$I_RES5A_ZM_2020 %in% '1' ~ 'No pertenecen a la Zona Metropolitana', #Migrantes que residian dentro de una zona metropolitana
                                .$CVE_MUN != .$CVE_MUN_RES & .$I_ZM_2020 %in% '0' & .$I_RES5A_ZM_2020 %in% '0' ~ 'No pertenecen a la Zona Metropolitana' #Migrantes que no residen en la zona metropolitana
                                )) %>%
         filter(EDAD >= 5 & EDAD <= 130) %>%
          filter(CVE_MUN_RES %in% municipios) %>%
           svydesign(data = ., id = ~ UPM, strata = ~ESTRATO, weight = ~FACTOR, nest = T)

saveRDS(MC, file = paste0(here::here(), "/Output/Municipio/06_Zonas Metropolitanas/2010/01_Migracion reciente/Base 2020/MC_municipal_Base2020.RDS"))
MC <- readRDS(file = paste0(here::here(), "/Output/Municipio/06_Zonas Metropolitanas/2010/01_Migracion reciente/Base 2020/MC_municipal_Base2020.RDS"))

Migrantes <- svytable(~CVE_MUN_RES + CVE_MUN, design = MC) 

Se genera la matriz cuadrada y se le asignan los nombres de los estados.

Migrantes <- Migrantes %>%
              as.data.frame() %>%
               expss::cross_cases(CVE_MUN, CVE_MUN_RES, weight = Freq) %>%
                as.data.frame() %>%
                 rename("CVE_MUN" = "row_labels") %>% 
                  arrange(CVE_MUN) %>%
                   slice(-1) 

rownames <- Migrantes %>% 
             mutate(CVE_MUN = substr(.$CVE_MUN, 9, 16)) %>% 
              pull(CVE_MUN)

colnames <- names(Migrantes) %>% 
             as.data.frame() %>% 
              slice(-1) %>% 
               rename("CVE_MUN" = ".") %>%
                mutate(`CVE_MUN` = substr(.$CVE_MUN, 13, 20)) %>%
                 pull(CVE_MUN)

# Se elimina la variable CVE_MUN
Migrantes <- Migrantes %>%
              select(-CVE_MUN)

rownames(Migrantes) <- rownames
colnames(Migrantes) <- colnames

saveRDS(Migrantes, file = paste0(here::here(), "/Output/Municipio/06_Zonas Metropolitanas/2010/01_Migracion reciente/Base 2020/Matriz de migracion reciente a nivel municipal_Base2020.RDS"))
save(Migrantes, file = paste0(here::here(), "/Output/Municipio/06_Zonas Metropolitanas/2010/01_Migracion reciente/Base 2020/Matriz de migracion reciente a nivel municipal_Base2020.RData"))

require(openxlsx)
wb <- createWorkbook()
addWorksheet(wb, "M.Reciente")
writeData(wb, 1, Migrantes %>% as.data.frame() %>% tibble::rownames_to_column(var = "CVE_MUN"), colNames = TRUE)
saveWorkbook(wb, file = paste0(here::here(), "/Bases/Municipio/06_Zonas Metropolitanas/2010/01_Migracion reciente/Base 2020/Matriz de migracion reciente a nivel municipal_Base2020.xlsx"), overwrite = TRUE)

Matriz de migración reciente hace 5 años a nivel municipal, 2005 - 2010

Matriz de migración reciente 2005 - 2010
Nivel municipal
CVE_MUN 001001 001002 001003 001004 001005 001006 001007 001008 001009 001010 001011 002001 002002 002003 002004 002005 003001 003002 003003 003008 003009 004001 004002 004003 004004 004005 004006 004007 004008
001001 665374 597 552 0 762 121 124 17 98 17 269 104 235 182 359 0 0 0 0 70 0 0 0 0 0 0 0 0 0
001002 168 38598 0 0 0 12 0 0 0 15 9 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
001003 76 0 44589 14 16 0 22 0 0 11 0 0 0 0 11 0 0 0 0 0 0 0 0 11 0 0 0 0 0
001004 50 0 0 12248 0 0 19 0 0 4 12 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
001005 1875 22 0 0 77233 140 36 22 16 0 389 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
001006 145 36 0 6 140 33542 96 38 20 18 234 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
001007 36 45 18 54 45 75 40417 0 0 0 18 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
001008 52 8 8 2 10 20 14 5934 0 0 2 0 0 0 6 0 0 0 0 0 0 0 0 0 0 0 0 0 0
001009 90 10 0 25 0 53 258 10 16525 5 0 13 0 0 52 0 0 0 0 0 0 0 0 0 0 0 0 0 0
001010 78 33 0 0 4 0 0 5 0 15235 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
001011 2577 64 48 0 787 1068 204 22 80 0 24496 0 100 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
002001 67 0 0 0 0 0 0 0 0 0 0 367600 3703 142 3105 641 97 403 1370 47 0 0 0 0 57 0 0 0 0
002002 903 0 0 0 0 0 0 0 0 0 0 1889 798622 761 2416 536 48 189 72 25 0 0 0 0 0 0 0 0 0
002003 50 0 0 0 0 0 11 0 0 0 0 222 654 74714 1642 64 0 45 27 6 0 0 0 0 0 0 0 0 0
002004 812 0 0 0 12 147 0 0 0 0 0 1905 2442 472 1248126 1414 0 0 956 100 0 0 0 0 0 0 0 0 0
002005 78 0 0 0 0 0 0 0 0 0 0 276 434 35 3920 66316 0 0 36 10 0 0 0 26 0 0 0 0 0
003001 48 0 0 0 0 0 0 0 0 0 0 163 70 0 282 34 57665 310 1220 736 66 0 0 0 0 0 0 0 0
003002 233 0 0 0 0 0 0 0 0 0 0 990 35 15 260 45 56 43931 408 50 71 0 0 0 0 0 0 0 0
003003 0 0 0 0 0 0 0 0 0 0 0 603 449 0 854 0 2344 1108 204067 2520 391 0 0 0 0 0 0 0 0
003008 24 0 0 0 0 0 0 0 0 0 0 287 239 4 1374 56 260 13 1861 151222 180 0 0 0 0 0 0 0 0
003009 14 0 0 0 0 0 0 0 0 0 0 105 35 0 100 7 392 287 205 175 12240 0 0 0 0 0 0 0 0
004001 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 45660 0 11 11 33 11 11 0
004002 0 0 0 0 0 0 0 0 0 0 0 0 7 0 34 0 0 0 0 0 0 139 226429 277 285 146 94 13 6
004003 0 0 0 0 0 0 0 0 0 0 0 166 0 0 34 0 0 0 16 0 0 0 162 179398 66 0 0 226 0
004004 33 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 85 0 1024 67194 72 33 33 36
004005 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 38 10 30 25 23321 0 10 15
004006 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 26 14 14 42 21 32956 14 0
004007 0 0 0 0 0 0 0 0 0 0 0 0 0 3 0 0 0 0 0 0 0 3 0 24 3 0 0 8250 0
004008 0 0 0 0 0 0 0 0 0 0 0 0 0 0 4 0 0 0 0 0 0 15 38 14 9 37 9 10 8275
004009 0 0 0 0 0 0 0 0 0 0 0 0 0 0 11 0 0 0 0 0 0 22 11 462 240 110 11 0 0
Fuente: Estimaciones del CONAPO.

Indicadores

Se realizan cálculos generales de migración:

  • Residentes

  • Inmigrantes

  • Emigrantes

  • % Inmigrantes

  • % Emigrante

  • Migración bruta

  • Migración Neta

  • % Tasa de migración bruta

  • % Tasa de migración neta

Se trabaja con la matriz cuadrada, la cual de esta manera no se satura la computadora.

################################################################################
############################ Población total ###################################
Pob.Total <- mydata %>%
              as.data.frame() %>%
               group_by(CVE_MUN) %>%
                summarise(Pob.Total = sum(FACTOR)) 

################################################################################
###################### Población de 5 años y más ###############################
Pob.5ymas <- mydata %>%
              as.data.frame() %>%
               mutate(EDAD = as.numeric(.$EDAD)) %>%
                subset(EDAD >= 5 & EDAD <=130) %>%
                 group_by(CVE_MUN) %>%
                  summarise(Pob.5ymas = sum(FACTOR)) 

################################################################################
########################### Residentes #########################################
load(file = paste0(here::here(), "/Output/Municipio/06_Zonas Metropolitanas/2010/01_Migracion reciente/Base 2020/Matriz de migracion reciente a nivel municipal_Base2020.RData"))

Residentes <- Migrantes %>%
               rownames_to_column() %>%
                gather(CVE_MUN, Value, -rowname)%>%
                 filter(rowname == CVE_MUN) %>%
                  select(-rowname) %>%
                   droplevels() %>%
                    rename("Residentes" = "Value") 

################################################################################
############################### Inmigrantes ####################################
Inmigrantes <- Migrantes %>% 
                as.data.frame() %>%
                 tibble::rownames_to_column(var = "CVE_MUN") %>%
                  melt(., id.vars = "CVE_MUN", variable.name = "CVE_MUN_RES") %>%
                   mutate_at(vars(3), as.numeric) %>%
                    as_tibble() %>%
                     filter(CVE_MUN != CVE_MUN_RES) %>%
                      group_by(CVE_MUN) %>%
                       summarise(Inmigrantes = sum(value, na.rm = TRUE))

################################################################################
############################### Emigrantes #####################################
Emigrantes <- Migrantes %>% 
               as.data.frame() %>%
                tibble::rownames_to_column(var = "CVE_MUN") %>%
                 melt(., id.vars = "CVE_MUN", variable.name = "CVE_MUN_RES") %>%
                  mutate_at(vars(3), as.numeric) %>%
                   as_tibble() %>%
                    filter(CVE_MUN != CVE_MUN_RES) %>%
                     group_by(CVE_MUN_RES) %>%
                      summarise(Emigrantes = sum(value, na.rm = TRUE)) %>%
                       rename("CVE_MUN" = "CVE_MUN_RES") 

tabla <- Pob.Total %>%
          left_join(., Pob.5ymas, by = c("CVE_MUN")) %>%
          left_join(., Residentes, by = c("CVE_MUN")) %>%
          left_join(., Inmigrantes, by = c("CVE_MUN")) %>%
          left_join(., Emigrantes, by = c("CVE_MUN")) %>%
           mutate(Mig.Neta = .$Inmigrantes - .$Emigrantes,
                  Mig.Bruta = .$Inmigrantes + .$Emigrantes, 
                  Tasa.Inmig = ((.$Inmigrantes/ 5) /((.$Pob.Total + .$Pob.5ymas) / 2)) * 1000,
                  Tasa.Emig = ((.$Emigrantes/ 5) /((.$Pob.Total + .$Pob.5ymas) / 2)) * 1000,
                  Tasa.Mig = Tasa.Inmig - Tasa.Emig, 
                  Eficacia = Mig.Neta - Mig.Bruta)

write.xlsx(tabla, file = paste0(here::here(), "/Output/Municipio/06_Zonas Metropolitanas/2010/01_Migracion reciente/Base 2020/Indicadores de MR5a por ZM 2010_Base2020.xlsx"), overwrite = TRUE)
save(tabla, file = paste0(here::here(), "/Output/Municipio/06_Zonas Metropolitanas/2010/01_Migracion reciente/Base 2020/Indicadores de MR5a por ZM 2010_Base2020.RData"))
Indicadores de migración reciente a nivel municipal
Zonas Metropolitanas
CVE_MUN Pob.Total Pob.5ymas Residentes Inmigrantes Emigrantes Mig.Neta Mig.Bruta Tasa.Inmig Tasa.Emig Tasa.Mig Eficacia
001001 793 997 718 680 665 374 39 438 26 908 12 530 66 346 10.4 7.1 3.3 −53 816
001002 45 951 40 347 38 598 721 1 381 −660 2 102 3.3 6.4 −3.1 −2 762
001003 53 142 47 809 44 589 884 1 454 −570 2 338 3.5 5.8 −2.3 −2 908
001004 14 302 12 759 12 248 203 266 −63 469 3.0 3.9 −0.9 −532
001005 100 150 87 268 77 233 6 005 2 733 3 272 8 738 12.8 5.8 7.0 −5 466
001006 40 480 35 933 33 542 1 681 1 868 −187 3 549 8.8 9.8 −1.0 −3 736
001007 48 462 42 246 40 417 575 1 269 −694 1 844 2.5 5.6 −3.1 −2 538
001008 7 164 6 374 5 934 182 133 49 315 5.4 3.9 1.4 −266
001009 20 048 17 674 16 525 700 263 437 963 7.4 2.8 4.6 −526
001010 18 282 16 022 15 235 313 812 −499 1 125 3.6 9.5 −5.8 −1 624
001011 36 822 31 901 24 496 6 348 1 208 5 140 7 556 36.9 7.0 29.9 −2 416
002001 460 793 419 052 367 600 37 646 20 037 17 609 57 683 17.1 9.1 8.0 −40 074
002002 932 001 852 568 798 622 34 217 29 286 4 931 63 503 7.7 6.6 1.1 −58 572
002003 95 638 86 305 74 714 7 838 4 977 2 861 12 815 17.2 10.9 6.3 −9 954
002004 1 543 644 1 391 497 1 248 126 90 073 90 788 −715 180 861 12.3 12.4 −0.1 −181 576
002005 91 309 82 225 66 316 10 427 5 647 4 780 16 074 24.0 13.0 11.0 −11 294
003001 70 358 63 992 57 665 5 234 3 685 1 549 8 919 15.6 11.0 4.6 −7 370
003002 58 624 52 519 43 931 7 587 3 771 3 816 11 358 27.3 13.6 13.7 −7 542
003003 249 303 229 448 204 067 23 278 12 977 10 301 36 255 19.4 10.8 8.6 −25 954
003008 238 498 213 476 151 222 51 192 13 125 38 067 64 317 45.3 11.6 33.7 −26 250
Fuente: Estimaciones del CONAPO.

Se genera la matriz cuadrada y se le asignan los nombres de los estados.

Migración intramunicipal

Matrices

Se utiliza la paquetería survey para poder trabajar con la muestra del cuestionario ampliado, en la cual se selecciona a la población de 5 años y más.

options(survey.lonely.psu = "adjust")

MC <- mydata %>%
       select(CVE_ENT, CVE_MUN, RES05EDO_C, CVE_MUN_RES, CVE_ZM, CVE_ZM_RES, M, EDAD, FACTOR, ESTRATO, UPM) %>%
        # Se genera una indicadora de zm 
        mutate(I_ZM_2020 = ifelse(is.na(.$CVE_ZM), '0', '1'),
               I_RES5A_ZM_2020 = ifelse(is.na(.$CVE_ZM_RES), '0', '1')) %>%
        # Se clasifican a los migrantes internos 
        mutate(I_ZM = case_when(.$CVE_MUN == .$CVE_MUN_RES ~ 'Pertenecen a la Zona Metropolitana', #Residentes
                                .$CVE_MUN != .$CVE_MUN_RES & .$I_ZM_2020 %in% '1' & .$I_RES5A_ZM_2020 %in% '1' & .$CVE_ZM == .$CVE_ZM_RES ~ "Pertenecen a la Zona Metropolitana", #Migrantes que residen en la misma zona metropolitana
                                .$CVE_MUN != .$CVE_MUN_RES & .$I_ZM_2020 %in% '1' & .$I_RES5A_ZM_2020 %in% '1' & .$CVE_ZM != .$CVE_ZM_RES ~ 'No pertenecen a la Zona Metropolitana', #Migrantes que residen en otra zona metropolitana
                                .$CVE_MUN != .$CVE_MUN_RES & .$I_ZM_2020 %in% '1' & .$I_RES5A_ZM_2020 %in% '0' ~ 'No pertenecen a la Zona Metropolitana', #Migrantes que residian fuera de la zona metropolitana
                                .$CVE_MUN != .$CVE_MUN_RES & .$I_ZM_2020 %in% '0' & .$I_RES5A_ZM_2020 %in% '1' ~ 'No pertenecen a la Zona Metropolitana', #Migrantes que residian dentro de una zona metropolitana
                                .$CVE_MUN != .$CVE_MUN_RES & .$I_ZM_2020 %in% '0' & .$I_RES5A_ZM_2020 %in% '0' ~ 'No pertenecen a la Zona Metropolitana' #Migrantes que no residen en la zona metropolitana
                                )) %>%
         filter(EDAD >= 5 & EDAD <= 130) %>%
          filter(CVE_MUN_RES %in% municipios & .$I_ZM %in% "Pertenecen a la Zona Metropolitana") %>%
           svydesign(data = ., id = ~ UPM, strata = ~ESTRATO, weight = ~FACTOR, nest = T)

saveRDS(MC, file = paste0(here::here(), "/Output/Municipio/06_Zonas Metropolitanas/2010/01_Migracion reciente/Base 2020/MC_intramunicipal_Base2020.RDS"))

Se genera una matriz cruzada del lugar de residencia hace 5 años a nivel municipal, utilizando la función svytable de la paquetería survey.

MC <- readRDS(file = paste0(here::here(), "/Output/Municipio/06_Zonas Metropolitanas/2010/01_Migracion reciente/Base 2020/MC_intramunicipal_Base2020.RDS"))

Migrantes <- svytable(~CVE_MUN_RES + CVE_MUN, design = MC)

Se genera la matriz cuadrada y se le asignan las etiquetas de municipios.

Migrantes <- Migrantes %>%
              as.data.frame() %>%
               expss::cross_cases(CVE_MUN, CVE_MUN_RES, weight = Freq) %>%
                as.data.frame() %>%
                 rename("CVE_MUN" = "row_labels") %>% 
                  arrange(CVE_MUN) %>%
                   slice(-1) 
            
rownames <- Migrantes %>% 
             mutate(CVE_MUN = substr(.$CVE_MUN, 9, 16)) %>% 
              pull(CVE_MUN)

colnames <- names(Migrantes) %>% 
             as.data.frame() %>% 
              slice(-1) %>% 
               rename("CVE_MUN" = ".") %>%
                mutate(`CVE_MUN` = substr(.$CVE_MUN, 13, 20)) %>%
                 pull(CVE_MUN)

# Se elimina la variable CVE_MUN
Migrantes <- Migrantes %>%
              select(-CVE_MUN)

rownames(Migrantes) <- rownames
colnames(Migrantes) <- colnames

saveRDS(Migrantes, file = paste0(here::here(), "/Output/Municipio/06_Zonas Metropolitanas/2010/01_Migracion reciente/Base 2020/Matriz de migracion reciente a nivel intramunicipal 2010_Base2020.RDS"))
save(Migrantes, file = paste0(here::here(), "/Output/Municipio/06_Zonas Metropolitanas/2010/01_Migracion reciente/Base 2020/Matriz de migracion reciente a nivel intramunicipal 2010_Base2020.RData"))

require(openxlsx)
wb <- createWorkbook()
addWorksheet(wb, "M.Intramunicipal")
writeData(wb, 1, Migrantes %>% as.data.frame() %>% tibble::rownames_to_column(var = "CVE_MUN"), colNames = TRUE)
saveWorkbook(wb, file = paste0(here::here(), "/Bases/Municipio/06_Zonas Metropolitanas/2010/01_Migracion reciente/Base 2020/Matriz de migracion reciente a nivel intramunicipal 2010_Base2020.xlsx"), overwrite = TRUE)

Matriz de migración reciente hace 5 años a nivel municipal, 2005 - 2010

Matriz de migración reciente por zonas metropolitanas
Nivel intramunicipal
CVE_MUN 001001 001002 001003 001004 001005 001006 001007 001008 001009 001010 001011 002001 002002 002003 002004 002005 003001 003002 003003 003008 003009 004001 004002 004003 004004 004005 004006 004007 004008
001001 665374 0 0 0 762 0 0 0 0 0 269 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
001002 0 38598 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
001003 0 0 44589 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
001004 0 0 0 12248 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
001005 1875 0 0 0 77233 0 0 0 0 0 389 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
001006 0 0 0 0 0 33542 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
001007 0 0 0 0 0 0 40417 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
001008 0 0 0 0 0 0 0 5934 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
001009 0 0 0 0 0 0 0 0 16525 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
001010 0 0 0 0 0 0 0 0 0 15235 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
001011 2577 0 0 0 787 0 0 0 0 0 24496 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
002001 0 0 0 0 0 0 0 0 0 0 0 367600 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
002002 0 0 0 0 0 0 0 0 0 0 0 0 8e+05 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
002003 0 0 0 0 0 0 0 0 0 0 0 0 0 74714 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
002004 0 0 0 0 0 0 0 0 0 0 0 0 0 0 1248126 1414 0 0 0 0 0 0 0 0 0 0 0 0 0
002005 0 0 0 0 0 0 0 0 0 0 0 0 0 0 3920 66316 0 0 0 0 0 0 0 0 0 0 0 0 0
003001 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 57665 0 0 0 0 0 0 0 0 0 0 0 0
003002 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 43931 0 0 0 0 0 0 0 0 0 0 0
003003 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 2e+05 0 0 0 0 0 0 0 0 0 0
003008 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 151222 0 0 0 0 0 0 0 0 0
003009 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 12240 0 0 0 0 0 0 0 0
004001 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 45660 0 0 0 0 0 0 0
004002 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 226429 0 0 0 0 0 0
004003 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 179398 0 0 0 0 0
004004 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 67194 0 0 0 0
004005 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 23321 0 0 0
004006 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 32956 0 0
004007 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 8250 0
004008 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 8275
004009 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
Fuente: Estimaciones del CONAPO.

Matrices por zonas metropolitanas

MR <- NULL
for(i in 1:length(zm)){
tabla <- ZM_2020 %>%
          filter(CVE_MUN %in% municipios) %>%
           select(CVE_ZM, CVE_MUN) %>%
            filter(CVE_ZM %in% zm[i]) %>%
             pull(CVE_MUN)

MR[[paste0(zm[i])]] <- Migrantes %>%
                        as.data.frame() %>%
                         tibble::rownames_to_column(var = "CVE_MUN") %>%
                          mutate_if(is.numeric, as.numeric) %>%
                           select(CVE_MUN, all_of(tabla)) %>%
                            filter(CVE_MUN %in% tabla)
}

# Se guardan en un objeto de R 
saveRDS(MR, file = paste0(here::here(), "/Output/Municipio/06_Zonas Metropolitanas/2010/01_Migracion reciente/Base 2020/Matrices de MR5a a nivel intramunicipal por ZM2010_Base2020.RDS"))

# Se genera un Excel con todas las matrices por ZM
wb <- createWorkbook()
for(i in 1:length(zm)){
addWorksheet(wb, paste0(zm[i]))
writeData(wb, i, MR[[paste0(zm[i])]] %>% as.data.frame())
saveWorkbook(wb, 
              file = paste0(here::here(), "/Bases/Municipio/06_Zonas Metropolitanas/2010/01_Migracion reciente/Base 2020/Matrices de MR5a a nivel intramunicipal por ZM2010_Base2020.xlsx"), 
               overwrite = TRUE)
}

Matriz de migración reciente hace 5 años en la Zona Metropolitana de Cuernavaca, 2005 - 2010

Matriz de migración reciente a nivel intramunicipal
Zona Metropolitana de Cuernavaca
CVE_MUN 017002 017004 017006 017030
017002 13258 30 386 30
017004 0 62756 1327 155
017006 13 277 144887 1175
017030 162 62 1326 37236
Fuente: Estimaciones del CONAPO.

Indicadores

Se realizan cálculos generales de migración:

  • Residentes

  • Inmigrantes

  • Emigrantes

  • % Inmigrantes

  • % Emigrante

  • Migración bruta

  • Migración Neta

  • % Tasa de migración bruta

  • % Tasa de migración neta

Se trabaja con la matriz cuadrada, la cual de esta manera no se satura la computadora.

################################################################################
############################ Población total ###################################
Pob.Total <- mydata %>%
              as.data.frame() %>%
               group_by(CVE_MUN) %>%
                summarise(Pob.Total = sum(FACTOR)) 

################################################################################
###################### Población de 5 años y más ###############################
Pob.5ymas <- mydata %>%
              as.data.frame() %>%
               mutate(EDAD = as.numeric(.$EDAD)) %>%
                subset(EDAD >= 5 & EDAD <=130) %>%
                 group_by(CVE_MUN) %>%
                  summarise(Pob.5ymas = sum(FACTOR)) 

################################################################################
########################### Residentes #########################################
load(file = paste0(here::here(), "/Output/Municipio/06_Zonas Metropolitanas/2010/01_Migracion reciente/Base 2020/Matriz de migracion reciente a nivel intramunicipal 2010_Base2020.RData"))

Residentes <- Migrantes %>%
               rownames_to_column() %>%
                gather(CVE_MUN, Value, -rowname)%>%
                 filter(rowname == CVE_MUN) %>%
                  select(-rowname) %>%
                   droplevels() %>%
                    rename("Residentes" = "Value") 

################################################################################
############################### Inmigrantes ####################################
Inmigrantes <- Migrantes %>% 
                as.data.frame() %>%
                 tibble::rownames_to_column(var = "CVE_MUN") %>%
                  melt(., id.vars = "CVE_MUN", variable.name = "CVE_MUN_RES") %>%
                   mutate_at(vars(3), as.numeric) %>%
                    as_tibble() %>%
                     filter(CVE_MUN != CVE_MUN_RES) %>%
                      group_by(CVE_MUN) %>%
                       summarise(Inmigrantes = sum(value, na.rm = TRUE))

################################################################################
############################### Emigrantes #####################################
Emigrantes <- Migrantes %>% 
               as.data.frame() %>%
                tibble::rownames_to_column(var = "CVE_MUN") %>%
                 melt(., id.vars = "CVE_MUN", variable.name = "CVE_MUN_RES") %>%
                  mutate_at(vars(3), as.numeric) %>%
                   as_tibble() %>%
                    filter(CVE_MUN != CVE_MUN_RES) %>%
                     group_by(CVE_MUN_RES) %>%
                      summarise(Emigrantes = sum(value, na.rm = TRUE)) %>%
                       rename("CVE_MUN" = "CVE_MUN_RES") 

tabla <- Pob.Total %>%
          left_join(., Pob.5ymas, by = c("CVE_MUN")) %>%
          left_join(., Residentes, by = c("CVE_MUN")) %>%
          left_join(., Inmigrantes, by = c("CVE_MUN")) %>%
          left_join(., Emigrantes, by = c("CVE_MUN")) %>%
           mutate(Mig.Neta = .$Inmigrantes - .$Emigrantes,
                  Mig.Bruta = .$Inmigrantes + .$Emigrantes, 
                  Tasa.Inmig = ((.$Inmigrantes/ 5) /((.$Pob.Total + .$Pob.5ymas) / 2)) * 1000,
                  Tasa.Emig = ((.$Emigrantes/ 5) /((.$Pob.Total + .$Pob.5ymas) / 2)) * 1000,
                  Tasa.Mig = Tasa.Inmig - Tasa.Emig, 
                  Eficacia = Mig.Neta - Mig.Bruta)

write.xlsx(tabla, 
            file = paste0(here::here(), "/Output/Municipio/06_Zonas Metropolitanas/2010/01_Migracion reciente/Base 2020/Indicadores de MR5a por ZM 2010 (Intramunicipal)_Base2020.xlsx"), 
             overwrite = TRUE)

save(tabla, file = paste0(here::here(), "/Output/Municipio/06_Zonas Metropolitanas/2010/01_Migracion reciente/Base 2020/Indicadores de MR5a por ZM 2010 (Intramunicipal)_Base2020.RData"))
Indicadores de migración reciente a nivel intramunicipal
Zonas Metropolitanas
CVE_MUN Pob.Total Pob.5ymas Residentes Inmigrantes Emigrantes Mig.Neta Mig.Bruta Tasa.Inmig Tasa.Emig Tasa.Mig Eficacia
001001 793 997 718 680 665 374 1 031 4 452 −3 421 5 483 0.27 1.18 −0.9 −8 904
001002 45 951 40 347 38 598 0 0 0 0 0.00 0.00 0.0 0
001003 53 142 47 809 44 589 0 0 0 0 0.00 0.00 0.0 0
001004 14 302 12 759 12 248 0 0 0 0 0.00 0.00 0.0 0
001005 100 150 87 268 77 233 2 264 1 549 715 3 813 4.83 3.31 1.5 −3 098
001006 40 480 35 933 33 542 0 0 0 0 0.00 0.00 0.0 0
001007 48 462 42 246 40 417 0 0 0 0 0.00 0.00 0.0 0
001008 7 164 6 374 5 934 0 0 0 0 0.00 0.00 0.0 0
001009 20 048 17 674 16 525 0 0 0 0 0.00 0.00 0.0 0
001010 18 282 16 022 15 235 0 0 0 0 0.00 0.00 0.0 0
001011 36 822 31 901 24 496 3 364 658 2 706 4 022 19.58 3.83 15.8 −1 316
002001 460 793 419 052 367 600 0 0 0 0 0.00 0.00 0.0 0
002002 932 001 852 568 798 622 0 0 0 0 0.00 0.00 0.0 0
002003 95 638 86 305 74 714 0 0 0 0 0.00 0.00 0.0 0
002004 1 543 644 1 391 497 1 248 126 1 414 3 920 −2 506 5 334 0.19 0.53 −0.3 −7 840
002005 91 309 82 225 66 316 3 920 1 414 2 506 5 334 9.04 3.26 5.8 −2 828
003001 70 358 63 992 57 665 0 0 0 0 0.00 0.00 0.0 0
003002 58 624 52 519 43 931 0 0 0 0 0.00 0.00 0.0 0
003003 249 303 229 448 204 067 0 0 0 0 0.00 0.00 0.0 0
003008 238 498 213 476 151 222 0 0 0 0 0.00 0.00 0.0 0
Fuente: Estimaciones del CONAPO.

Migración intermunicipal

Matrices

options(survey.lonely.psu = "adjust")

MC <- mydata %>%
       select(CVE_ENT, CVE_MUN, RES05EDO_C, CVE_MUN_RES, CVE_ZM, CVE_ZM_RES, M, EDAD, FACTOR, ESTRATO, UPM) %>%
        # Se genera una indicadora de zm 
        mutate(I_ZM_2020 = ifelse(is.na(.$CVE_ZM), '0', '1'),
               I_RES5A_ZM_2020 = ifelse(is.na(.$CVE_ZM_RES), '0', '1')) %>%
        # Se clasifican a los migrantes internos 
        mutate(I_ZM = case_when(.$CVE_MUN == .$CVE_MUN_RES ~ 'Pertenecen a la Zona Metropolitana', #Residentes
                                .$CVE_MUN != .$CVE_MUN_RES & .$I_ZM_2020 %in% '1' & .$I_RES5A_ZM_2020 %in% '1' & .$CVE_ZM == .$CVE_ZM_RES ~ "Pertenecen a la Zona Metropolitana", #Migrantes que residen en la misma zona metropolitana
                                .$CVE_MUN != .$CVE_MUN_RES & .$I_ZM_2020 %in% '1' & .$I_RES5A_ZM_2020 %in% '1' & .$CVE_ZM != .$CVE_ZM_RES ~ 'No pertenecen a la Zona Metropolitana', #Migrantes que residen en otra zona metropolitana
                                .$CVE_MUN != .$CVE_MUN_RES & .$I_ZM_2020 %in% '1' & .$I_RES5A_ZM_2020 %in% '0' ~ 'No pertenecen a la Zona Metropolitana', #Migrantes que residian fuera de la zona metropolitana
                                .$CVE_MUN != .$CVE_MUN_RES & .$I_ZM_2020 %in% '0' & .$I_RES5A_ZM_2020 %in% '1' ~ 'No pertenecen a la Zona Metropolitana', #Migrantes que residian dentro de una zona metropolitana
                                .$CVE_MUN != .$CVE_MUN_RES & .$I_ZM_2020 %in% '0' & .$I_RES5A_ZM_2020 %in% '0' ~ 'No pertenecen a la Zona Metropolitana' #Migrantes que no residen en la zona metropolitana
                                )) %>%
         filter(EDAD >= 5 & EDAD <= 130) %>%
          filter(CVE_MUN_RES %in% municipios & .$I_ZM %in% "No pertenecen a la Zona Metropolitana") %>%
           svydesign(data = ., id = ~ UPM, strata = ~ESTRATO, weight = ~FACTOR, nest = T)

saveRDS(MC, file = paste0(here::here(), "/Output/Municipio/06_Zonas Metropolitanas/2010/01_Migracion reciente/Base 2020/MC_intermunicipal_Base2020.RDS"))

Se genera una matriz cruzada del lugar de residencia hace 5 años a nivel municipal, utilizando la función svytable de la paquetería survey.

MC <- readRDS(file = paste0(here::here(), "/Output/Municipio/06_Zonas Metropolitanas/2010/01_Migracion reciente/Base 2020/MC_intermunicipal_Base2020.RDS"))

Migrantes <- svytable(~CVE_MUN_RES + CVE_MUN, design = MC)

Se genera la matriz cuadrada y se le asignan las etiquetas de municipios.

Migrantes <- Migrantes %>%
              as.data.frame() %>%
               expss::cross_cases(CVE_MUN, CVE_MUN_RES, weight = Freq) %>%
                as.data.frame() %>%
                 rename("CVE_MUN" = "row_labels") %>% 
                  arrange(CVE_MUN) %>%
                   slice(-1) 
            
rownames <- Migrantes %>% 
             mutate(CVE_MUN = substr(.$CVE_MUN, 9, 16)) %>% 
              pull(CVE_MUN)

colnames <- names(Migrantes) %>% 
             as.data.frame() %>% 
              slice(-1) %>% 
               rename("CVE_MUN" = ".") %>%
                mutate(`CVE_MUN` = substr(.$CVE_MUN, 13, 20)) %>%
                 pull(CVE_MUN)

# Se elimina la variable CVE_MUN
Migrantes <- Migrantes %>%
              select(-CVE_MUN)

rownames(Migrantes) <- rownames
colnames(Migrantes) <- colnames

saveRDS(Migrantes, file = paste0(here::here(), "/Output/Municipio/06_Zonas Metropolitanas/2010/01_Migracion reciente/Base 2020/Matriz de migracion reciente a nivel intermunicipal 2010_Base2020.RDS"))
save(Migrantes, file = paste0(here::here(), "/Output/Municipio/06_Zonas Metropolitanas/2010/01_Migracion reciente/Base 2020/Matriz de migracion reciente a nivel intermunicipal 2010_Base2020.RData"))

require(openxlsx)
wb <- createWorkbook()
addWorksheet(wb, "M.Intermunicipal")
writeData(wb, 1, Migrantes %>% as.data.frame() %>% tibble::rownames_to_column(var = "CVE_MUN"), colNames = TRUE)
saveWorkbook(wb, file = paste0(here::here(), "/Bases/Municipio/06_Zonas Metropolitanas/2010/01_Migracion reciente/Base 2020/Matriz de migracion reciente a nivel intermunicipal 2010_Base2020.xlsx"), overwrite = TRUE)

Matriz de migración reciente hace 5 años a nivel intermunicipal, 2005 - 2010

Matriz de migración reciente por zonas metropolitanas
Nivel intermunicipal
CVE_MUN 001001 001002 001003 001004 001005 001006 001007 001008 001009 001010 001011 002001 002002 002003 002004 002005 003001 003002 003003 003008 003009 004001 004002 004003 004004 004005 004006 004007 004008
001001 0 597 552 0 0 121 124 17 98 17 0 104 235 182 359 0 0 0 0 70 0 0 0 0 0 0 0 0 0
001002 168 0 0 0 0 12 0 0 0 15 9 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
001003 76 0 0 14 16 0 22 0 0 11 0 0 0 0 11 0 0 0 0 0 0 0 0 11 0 0 0 0 0
001004 50 0 0 0 0 0 19 0 0 4 12 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
001005 0 22 0 0 0 140 36 22 16 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
001006 145 36 0 6 140 0 96 38 20 18 234 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
001007 36 45 18 54 45 75 0 0 0 0 18 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
001008 52 8 8 2 10 20 14 0 0 0 2 0 0 0 6 0 0 0 0 0 0 0 0 0 0 0 0 0 0
001009 90 10 0 25 0 53 258 10 0 5 0 13 0 0 52 0 0 0 0 0 0 0 0 0 0 0 0 0 0
001010 78 33 0 0 4 0 0 5 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
001011 0 64 48 0 0 1068 204 22 80 0 0 0 100 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
002001 67 0 0 0 0 0 0 0 0 0 0 0 3703 142 3105 641 97 403 1370 47 0 0 0 0 57 0 0 0 0
002002 903 0 0 0 0 0 0 0 0 0 0 1889 0 761 2416 536 48 189 72 25 0 0 0 0 0 0 0 0 0
002003 50 0 0 0 0 0 11 0 0 0 0 222 654 0 1642 64 0 45 27 6 0 0 0 0 0 0 0 0 0
002004 812 0 0 0 12 147 0 0 0 0 0 1905 2442 472 0 0 0 0 956 100 0 0 0 0 0 0 0 0 0
002005 78 0 0 0 0 0 0 0 0 0 0 276 434 35 0 0 0 0 36 10 0 0 0 26 0 0 0 0 0
003001 48 0 0 0 0 0 0 0 0 0 0 163 70 0 282 34 0 310 1220 736 66 0 0 0 0 0 0 0 0
003002 233 0 0 0 0 0 0 0 0 0 0 990 35 15 260 45 56 0 408 50 71 0 0 0 0 0 0 0 0
003003 0 0 0 0 0 0 0 0 0 0 0 603 449 0 854 0 2344 1108 0 2520 391 0 0 0 0 0 0 0 0
003008 24 0 0 0 0 0 0 0 0 0 0 287 239 4 1374 56 260 13 1861 0 180 0 0 0 0 0 0 0 0
003009 14 0 0 0 0 0 0 0 0 0 0 105 35 0 100 7 392 287 205 175 0 0 0 0 0 0 0 0 0
004001 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 11 11 33 11 11 0
004002 0 0 0 0 0 0 0 0 0 0 0 0 7 0 34 0 0 0 0 0 0 139 0 277 285 146 94 13 6
004003 0 0 0 0 0 0 0 0 0 0 0 166 0 0 34 0 0 0 16 0 0 0 162 0 66 0 0 226 0
004004 33 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 85 0 1024 0 72 33 33 36
004005 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 38 10 30 25 0 0 10 15
004006 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 26 14 14 42 21 0 14 0
004007 0 0 0 0 0 0 0 0 0 0 0 0 0 3 0 0 0 0 0 0 0 3 0 24 3 0 0 0 0
004008 0 0 0 0 0 0 0 0 0 0 0 0 0 0 4 0 0 0 0 0 0 15 38 14 9 37 9 10 0
004009 0 0 0 0 0 0 0 0 0 0 0 0 0 0 11 0 0 0 0 0 0 22 11 462 240 110 11 0 0
Fuente: Estimaciones del CONAPO.

Indicadores

Se realizan cálculos generales de migración:

  • Residentes

  • Inmigrantes

  • Emigrantes

  • % Inmigrantes

  • % Emigrante

  • Migración bruta

  • Migración Neta

  • % Tasa de migración bruta

  • % Tasa de migración neta

Se trabaja con la matriz cuadrada, la cual de esta manera no se satura la computadora.

################################################################################
############################ Población total ###################################
Pob.Total <- mydata %>%
              as.data.frame() %>%
               group_by(CVE_MUN) %>%
                summarise(Pob.Total = sum(FACTOR)) 

################################################################################
###################### Población de 5 años y más ###############################
Pob.5ymas <- mydata %>%
              as.data.frame() %>%
               mutate(EDAD = as.numeric(.$EDAD)) %>%
                subset(EDAD >= 5 & EDAD <= 130) %>%
                 group_by(CVE_MUN) %>%
                  summarise(Pob.5ymas = sum(FACTOR)) 

################################################################################
########################### Residentes #########################################
load(file = paste0(here::here(), "/Output/Municipio/06_Zonas Metropolitanas/2010/01_Migracion reciente/Base 2020/Matriz de migracion reciente a nivel intermunicipal 2010_Base2020.RData"))

Residentes <- Migrantes %>%
               rownames_to_column() %>%
                gather(CVE_MUN, Value, -rowname)%>%
                 filter(rowname == CVE_MUN) %>%
                  select(-rowname) %>%
                   droplevels() %>%
                    rename("Residentes" = "Value") 

################################################################################
############################### Inmigrantes ####################################
Inmigrantes <- Migrantes %>% 
                as.data.frame() %>%
                 tibble::rownames_to_column(var = "CVE_MUN") %>%
                  melt(., id.vars = "CVE_MUN", variable.name = "CVE_MUN_RES") %>%
                   mutate_at(vars(3), as.numeric) %>%
                    as_tibble() %>%
                     filter(CVE_MUN != CVE_MUN_RES) %>%
                      group_by(CVE_MUN) %>%
                       summarise(Inmigrantes = sum(value, na.rm = TRUE))

################################################################################
############################### Emigrantes #####################################
Emigrantes <- Migrantes %>% 
               as.data.frame() %>%
                tibble::rownames_to_column(var = "CVE_MUN") %>%
                 melt(., id.vars = "CVE_MUN", variable.name = "CVE_MUN_RES") %>%
                  mutate_at(vars(3), as.numeric) %>%
                   as_tibble() %>%
                    filter(CVE_MUN != CVE_MUN_RES) %>%
                     group_by(CVE_MUN_RES) %>%
                      summarise(Emigrantes = sum(value, na.rm = TRUE)) %>%
                       rename("CVE_MUN" = "CVE_MUN_RES") 

tabla <- Pob.Total %>%
          left_join(., Pob.5ymas, by = c("CVE_MUN")) %>%
          left_join(., Residentes, by = c("CVE_MUN")) %>%
          left_join(., Inmigrantes, by = c("CVE_MUN")) %>%
          left_join(., Emigrantes, by = c("CVE_MUN")) %>%
           mutate(Mig.Neta = .$Inmigrantes - .$Emigrantes,
                  Mig.Bruta = .$Inmigrantes + .$Emigrantes, 
                  Tasa.Inmig = ((.$Inmigrantes/ 5) /((.$Pob.Total + .$Pob.5ymas) / 2)) * 1000,
                  Tasa.Emig = ((.$Emigrantes/ 5) /((.$Pob.Total + .$Pob.5ymas) / 2)) * 1000,
                  Tasa.Mig = Tasa.Inmig - Tasa.Emig, 
                  Eficacia = Mig.Neta - Mig.Bruta)

write.xlsx(tabla, file = paste0(here::here(), "/Output/Municipio/06_Zonas Metropolitanas/2010/01_Migracion reciente/Base 2020/Indicadores de MR5a por ZM 2010 (Intermunicipal)_Base2020.xlsx"), overwrite = TRUE)

save(tabla, file = paste0(here::here(), "/Output/Municipio/06_Zonas Metropolitanas/2010/01_Migracion reciente/Base 2020/Indicadores de MR5a por ZM 2010 (Intermunicipal)_Base2020.RData"))
Indicadores de migración reciente a nivel intermunicipal
Zonas Metropolitanas
CVE_MUN Pob.Total Pob.5ymas Residentes Inmigrantes Emigrantes Mig.Neta Mig.Bruta Tasa.Inmig Tasa.Emig Tasa.Mig Eficacia
001001 793 997 718 680 0 38 407 22 456 15 951 60 863 10.2 5.9 4.2 −44 912
001002 45 951 40 347 0 721 1 381 −660 2 102 3.3 6.4 −3.1 −2 762
001003 53 142 47 809 0 884 1 454 −570 2 338 3.5 5.8 −2.3 −2 908
001004 14 302 12 759 0 203 266 −63 469 3.0 3.9 −0.9 −532
001005 100 150 87 268 0 3 741 1 184 2 557 4 925 8.0 2.5 5.5 −2 368
001006 40 480 35 933 0 1 681 1 868 −187 3 549 8.8 9.8 −1.0 −3 736
001007 48 462 42 246 0 575 1 269 −694 1 844 2.5 5.6 −3.1 −2 538
001008 7 164 6 374 0 182 133 49 315 5.4 3.9 1.4 −266
001009 20 048 17 674 0 700 263 437 963 7.4 2.8 4.6 −526
001010 18 282 16 022 0 313 812 −499 1 125 3.6 9.5 −5.8 −1 624
001011 36 822 31 901 0 2 984 550 2 434 3 534 17.4 3.2 14.2 −1 100
002001 460 793 419 052 0 37 646 20 037 17 609 57 683 17.1 9.1 8.0 −40 074
002002 932 001 852 568 0 34 217 29 286 4 931 63 503 7.7 6.6 1.1 −58 572
002003 95 638 86 305 0 7 838 4 977 2 861 12 815 17.2 10.9 6.3 −9 954
002004 1 543 644 1 391 497 0 88 659 86 868 1 791 175 527 12.1 11.8 0.2 −173 736
002005 91 309 82 225 0 6 507 4 233 2 274 10 740 15.0 9.8 5.2 −8 466
003001 70 358 63 992 0 5 234 3 685 1 549 8 919 15.6 11.0 4.6 −7 370
003002 58 624 52 519 0 7 587 3 771 3 816 11 358 27.3 13.6 13.7 −7 542
003003 249 303 229 448 0 23 278 12 977 10 301 36 255 19.4 10.8 8.6 −25 954
003008 238 498 213 476 0 51 192 13 125 38 067 64 317 45.3 11.6 33.7 −26 250
Fuente: Estimaciones del CONAPO.

Movilidad metropolitana

Se utiliza la paquetería survey para poder trabajar con la muestra del cuestionario ampliado, en la cual se selecciona a la población de 5 años y más.

options(survey.lonely.psu = "adjust")

MC <- mydata %>%
       select(CVE_ENT, CVE_MUN, RES05EDO_C, CVE_MUN_RES, CVE_ZM, CVE_ZM_RES, M, EDAD, FACTOR, ESTRATO, UPM) %>%
        # Se genera una indicadora de zm 
        mutate(I_ZM_2020 = ifelse(is.na(.$CVE_ZM), '0', '1'),
               I_RES5A_ZM_2020 = ifelse(is.na(.$CVE_ZM_RES), '0', '1')) %>%
        # Se clasifican a los migrantes internos 
        mutate(I_ZM = case_when(.$CVE_MUN == .$CVE_MUN_RES ~ 'Pertenecen a la Zona Metropolitana', #Residentes
                                .$CVE_MUN != .$CVE_MUN_RES & .$I_ZM_2020 %in% '1' & .$I_RES5A_ZM_2020 %in% '1' & .$CVE_ZM == .$CVE_ZM_RES ~ "Pertenecen a la Zona Metropolitana", #Migrantes que residen en la misma zona metropolitana
                                .$CVE_MUN != .$CVE_MUN_RES & .$I_ZM_2020 %in% '1' & .$I_RES5A_ZM_2020 %in% '1' & .$CVE_ZM != .$CVE_ZM_RES ~ 'No pertenecen a la Zona Metropolitana', #Migrantes que residen en otra zona metropolitana
                                .$CVE_MUN != .$CVE_MUN_RES & .$I_ZM_2020 %in% '1' & .$I_RES5A_ZM_2020 %in% '0' ~ 'No pertenecen a la Zona Metropolitana', #Migrantes que residian fuera de la zona metropolitana
                                .$CVE_MUN != .$CVE_MUN_RES & .$I_ZM_2020 %in% '0' & .$I_RES5A_ZM_2020 %in% '1' ~ 'No pertenecen a la Zona Metropolitana', #Migrantes que residian dentro de una zona metropolitana
                                .$CVE_MUN != .$CVE_MUN_RES & .$I_ZM_2020 %in% '0' & .$I_RES5A_ZM_2020 %in% '0' ~ 'No pertenecen a la Zona Metropolitana' #Migrantes que no residen en la zona metropolitana
                                )) %>%
         filter(EDAD >= 5 & EDAD <= 130) %>%
          filter(CVE_MUN_RES %in% municipios) %>%
           svydesign(data = ., id = ~ UPM, strata = ~ESTRATO, weight = ~FACTOR, nest = T)

saveRDS(MC, file = paste0(here::here(), "/Output/Municipio/06_Zonas Metropolitanas/2010/01_Migracion reciente/Base 2020/MC_metropolitana_Base2020.RDS"))

Matrices

Se genera una matriz cruzada del lugar de residencia hace 5 años a nivel municipal, utilizando la función svytable de la paquetería survey.

MC <- readRDS(file = paste0(here::here(), "/Output/Municipio/06_Zonas Metropolitanas/2010/01_Migracion reciente/Base 2020/MC_metropolitana_Base2020.RDS"))

Migrantes <- svytable(~CVE_ZM_RES + CVE_ZM, design = MC)

Se genera la matriz cuadrada y se le asignan las etiquetas de municipios.

Migrantes <- Migrantes %>%
              as.data.frame() %>%
               expss::cross_cases(CVE_ZM, CVE_ZM_RES, weight = Freq) %>%
                as.data.frame() %>%
                 rename("CVE_ZM" = "row_labels") %>% 
                  arrange(CVE_ZM) %>%
                   slice(-1) 
            
rownames <- Migrantes %>% 
             mutate(CVE_ZM = substr(.$CVE_ZM, 8, 12)) %>% 
              pull(CVE_ZM)

colnames <- names(Migrantes) %>% 
             as.data.frame() %>% 
              slice(-1) %>% 
               rename("CVE_ZM" = ".") %>%
                mutate(`CVE_ZM` = substr(.$CVE_ZM, 12, 16)) %>%
                 pull(CVE_ZM)

# Se elimina la variable CVE_ZM
Migrantes <- Migrantes %>%
              select(-CVE_ZM)

rownames(Migrantes) <- rownames
colnames(Migrantes) <- colnames

saveRDS(Migrantes, file = paste0(here::here(), "/Output/Municipio/06_Zonas Metropolitanas/2010/01_Migracion reciente/Base 2020/Matriz de MR5a a nivel metropolitano 2010_Base2020.RDS"))
save(Migrantes, file = paste0(here::here(), "/Output/Municipio/06_Zonas Metropolitanas/2010/01_Migracion reciente/Base 2020/Matriz de MR5a a nivel metropolitano 2010_Base2020.RData"))

require(openxlsx)
wb <- createWorkbook()
addWorksheet(wb, "M.Metropolitano")
writeData(wb, 1, Migrantes %>% as.data.frame() %>% tibble::rownames_to_column(var = "CVE_ZM"), colNames = TRUE)
saveWorkbook(wb, file = paste0(here::here(), "/Bases/Municipio/06_Zonas Metropolitanas/2010/01_Migracion reciente/Base 2020/Matriz de MR5a a nivel metropolitano 2010_Base2020.xlsx"), overwrite = TRUE)

Matriz de migración reciente hace 5 años a nivel municipal, 2005 - 2010

Matriz de migración reciente por zonas metropolitanas
Zonas metropolitanas
CVE_ZM 01.01 02.01 02.02 02.03 03.01 03.02 04.01 05.01 05.02 05.03 05.04 05.05 06.01 06.02 07.01 07.02 08.01 08.02 08.03 08.04 09.01 10.01 11.01 11.02 11.03 11.04 11.06 11.07 12.01
01.01 773762 104 335 359 0 70 0 587 124 0 20 0 42 8 42 386 465 0 12 605 1.1e+04 139 486 114 959 0 458 132 450
02.01 67 367600 3703 3746 1370 47 0 154 0 0 0 0 10 0 306 87 18 0 0 166 1.6e+03 324 209 0 0 0 0 21 272
02.02 903 1889 798622 2952 72 25 0 224 0 0 0 0 44 0 51 75 115 16 0 299 1.2e+03 64 88 91 184 0 352 184 12
02.03 902 2181 2876 1319776 992 110 0 530 0 0 105 0 987 166 1926 1770 699 248 260 758 6.8e+03 808 45 170 1432 33 347 44 2695
03.01 0 603 449 854 204067 2520 0 127 0 30 42 0 106 0 594 69 350 0 42 471 1.7e+03 346 41 0 77 0 0 0 195
03.02 24 287 239 1430 1861 151222 0 840 0 8 217 0 18 0 638 51 25 0 0 189 1.0e+04 279 0 5 324 0 360 0 3786
04.01 0 0 7 34 0 0 226429 30 21 0 26 0 0 0 168 12 0 0 0 0 2.2e+02 0 0 54 0 0 0 0 0
05.01 144 0 369 324 33 2 0 1049160 120 145 329 0 24 0 0 95 844 228 52 10130 1.6e+03 4635 41 13 88 0 0 0 34
05.02 70 0 0 41 0 0 0 353 292568 824 1571 211 0 0 100 14 91 2 0 104 1.7e+02 8 0 135 6 0 0 0 6
05.03 0 0 88 0 0 0 0 445 1175 147031 937 678 26 0 0 0 6 0 48 0 2.2e+02 48 26 7 163 0 0 7 0
05.04 420 0 74 141 0 0 0 1497 1730 769 693553 324 39 0 0 198 723 20 0 752 1.1e+03 16 128 16 286 0 92 66 27
05.05 0 0 0 34 0 0 0 102 443 211 146 87585 0 0 0 51 0 0 0 0 1.1e+01 0 0 34 0 0 0 0 17
06.01 148 158 242 560 39 20 0 50 48 36 36 0 227959 1894 19 23 68 0 0 192 1.8e+03 37 124 56 61 0 10 0 72
06.02 0 35 56 459 14 36 0 0 0 0 13 0 686 114599 84 38 93 0 0 16 2.8e+02 40 0 0 50 0 10 0 128
07.01 50 47 40 693 0 275 0 5 0 5 0 0 10 0 306713 782 0 10 0 129 7.8e+02 0 0 6 18 0 168 10 453
07.02 0 13 38 234 0 24 1176 32 0 0 4 0 0 0 2723 630561 27 22 0 148 2.9e+03 0 0 0 20 0 0 0 0
08.01 0 248 298 226 108 35 24 270 35 0 498 0 138 0 0 58 736724 393 2752 2124 1.2e+03 460 0 0 148 0 23 8 184
08.02 18 0 40 50 0 0 0 157 36 0 0 0 0 0 0 15 1125 166322 225 1655 1.8e+02 109 0 16 0 0 9 0 13
08.03 11 0 2 123 0 0 0 195 0 0 14 0 0 0 0 0 418 75 95325 846 5.2e+01 131 0 0 0 0 0 0 0
08.04 149 86 17 606 0 58 0 4538 24 13 404 0 56 48 374 0 2363 1108 859 1126568 1.5e+03 2561 34 22 241 0 62 0 326
09.01 3068 731 1461 6144 1006 1452 233 1297 125 121 775 20 490 14 975 3374 2281 212 93 2971 1.7e+07 1542 1602 1151 4100 507 1237 208 7328
10.01 76 6 102 549 16 60 0 655 7 56 115 0 0 0 0 174 158 8 69 2854 3.4e+02 491821 197 0 0 0 0 0 23
11.01 225 9 0 40 83 7 115 69 0 96 278 6 5 6 0 0 88 44 0 245 3.3e+03 261 519142 217 526 8 382 56 26
11.02 0 0 0 7 0 0 0 50 0 0 0 0 0 0 0 25 0 0 25 29 2.7e+02 0 216 147799 394 33 243 68 0
11.03 705 33 0 367 0 217 0 73 0 0 843 0 233 0 0 103 0 0 0 141 9.1e+03 158 491 281 1389409 9 981 1207 287
11.04 14 42 0 20 0 0 0 0 0 0 0 0 14 30 0 0 0 0 0 45 3.1e+02 0 27 110 55 121650 74 14 0
11.06 307 36 20 66 0 0 40 12 0 116 413 0 0 0 60 165 33 160 0 1 2.4e+03 72 400 197 645 108 457157 127 36
11.07 98 0 0 7 0 7 0 7 0 0 86 0 0 0 0 0 0 0 0 5 6.7e+02 0 169 125 1153 0 126 193833 0
12.01 146 80 70 800 30 504 0 36 0 0 0 0 61 0 0 0 0 0 0 193 3.6e+03 0 84 4 44 0 0 0 680792
12.02 0 0 36 0 30 36 0 0 0 0 0 0 82 0 0 0 20 0 0 26 6.4e+02 5 24 0 0 0 24 0 1089
Fuente: Estimaciones del CONAPO.

Indicadores

Se realizan cálculos generales de migración:

  • Residentes

  • Inmigrantes

  • Emigrantes

  • % Inmigrantes

  • % Emigrante

  • Migración bruta

  • Migración Neta

  • % Tasa de migración bruta

  • % Tasa de migración neta

Se trabaja con la matriz cuadrada, la cual de esta manera no se satura la computadora.

################################################################################
############################ Población total ###################################
Pob.Total <- mydata %>%
              as.data.frame() %>%
               group_by(CVE_ZM) %>%
                summarise(Pob.Total = sum(FACTOR)) 

################################################################################
###################### Población de 5 años y más ###############################
Pob.5ymas <- mydata %>%
              as.data.frame() %>%
               mutate(EDAD = as.numeric(.$EDAD)) %>%
                subset(EDAD >= 5 & EDAD <= 130) %>%
                 group_by(CVE_ZM) %>%
                  summarise(Pob.5ymas = sum(FACTOR)) 

################################################################################
########################### Residentes #########################################
load(file = paste0(here::here(), "/Output/Municipio/06_Zonas Metropolitanas/2010/01_Migracion reciente/Base 2020/Matriz de migracion reciente a nivel municipal_Base2020.RData"))

ZM <- lapply(1:length(zm), function(x){
                 ZM_2020 %>% 
                  select(CVE_ZM, CVE_MUN, NOM_MUN) %>%
                   filter(CVE_ZM %in% zm[x])  %>% 
                    pull(CVE_MUN)
})

Residentes <- lapply(1:length(zm), function(x){
                                     Migrantes %>% 
                                      as.data.frame() %>%
                                       tibble::rownames_to_column(var = "CVE_MUN") %>%
                                        melt(., id.vars =  "CVE_MUN", variable.name = "CVE_MUN_RES") %>%
                                         mutate_at(vars(3), as.numeric) %>%
                                          filter(CVE_MUN == CVE_MUN_RES)  %>%
                                           filter(CVE_MUN %in% ZM[[x]]) %>%
                                            summarize(Residentes =  sum(value, na.rm = TRUE)) %>% 
                                             mutate(CVE_ZM = !!paste0(zm[x])) 
})

Residentes <- do.call(rbind.data.frame, Residentes)

################################################################################
############################### Inmigrantes ####################################
Inmigrantes <- lapply(1:length(zm), function(x){
                                     Migrantes %>% 
                                      as.data.frame() %>%
                                       tibble::rownames_to_column(var = "CVE_MUN") %>%
                                        melt(., id.vars =  "CVE_MUN", variable.name = "CVE_MUN_RES") %>%
                                         mutate_at(vars(3), as.numeric) %>%
                                          filter(CVE_MUN != CVE_MUN_RES)  %>%
                                           filter(CVE_MUN %in% ZM[[x]]) %>%
                                            summarize(Inmigrantes =  sum(value, na.rm = TRUE)) %>% 
                                             mutate(CVE_ZM = !!paste0(zm[x])) 
})

Inmigrantes <- do.call(rbind.data.frame, Inmigrantes)

################################################################################
############################### Emigrantes #####################################
Emigrantes <- lapply(1:length(zm), function(x){
                                     Migrantes %>% 
                                      t() %>%
                                       as.data.frame() %>%
                                        tibble::rownames_to_column(var = "CVE_MUN") %>%
                                         melt(., id.vars =  "CVE_MUN", variable.name = "CVE_MUN_RES") %>%
                                          mutate_at(vars(3), as.numeric) %>%
                                           filter(CVE_MUN != CVE_MUN_RES)  %>%
                                           filter(CVE_MUN %in% ZM[[x]]) %>%
                                            summarize(Emigrantes =  sum(value, na.rm = TRUE)) %>% 
                                             mutate(CVE_ZM = !!paste0(zm[x])) 
})

Emigrantes <- do.call(rbind.data.frame, Emigrantes)

tabla <- Pob.Total %>%
          left_join(., Pob.5ymas, by = c("CVE_ZM")) %>%
          left_join(., Residentes, by = c("CVE_ZM")) %>%
          left_join(., Inmigrantes, by = c("CVE_ZM")) %>%
          left_join(., Emigrantes, by = c("CVE_ZM")) %>%
           mutate(Mig.Neta = .$Inmigrantes - .$Emigrantes,
                  Mig.Bruta = .$Inmigrantes + .$Emigrantes, 
                  Tasa.Inmig = ((.$Inmigrantes/ 5) /((.$Pob.Total + .$Pob.5ymas) / 2)) * 1000,
                  Tasa.Emig = ((.$Emigrantes/ 5) /((.$Pob.Total + .$Pob.5ymas) / 2)) * 1000,
                  Tasa.Mig = Tasa.Inmig - Tasa.Emig, 
                  Eficacia = Mig.Neta - Mig.Bruta)

write.xlsx(tabla, file = paste0(here::here(), "/Output/Municipio/06_Zonas Metropolitanas/2010/01_Migracion reciente/Base 2020/Indicadores de MR5a por ZM 2010 (Metropolitano) 2010_Base2020.xlsx"), overwrite = TRUE)
save(tabla, file = paste0(here::here(), "/Output/Municipio/06_Zonas Metropolitanas/2010/01_Migracion reciente/Base 2020/Indicadores de MR5a por ZM 2010 (Metropolitano) 2010_Base2020.RData"))
Indicadores de migración reciente (Nivel metropolitano)
Zonas Metropolitanas
CVE_ZM Pob.Total Pob.5ymas Residentes Inmigrantes Emigrantes Mig.Neta Mig.Bruta Tasa.Inmig Tasa.Emig Tasa.Mig Eficacia
01.01 930 969 837 849 767 103 51 791 30 849 20 942 82 640 11.7 7.0 4.7 −61 698
02.01 460 793 419 052 367 600 37 646 20 037 17 609 57 683 17.1 9.1 8.0 −40 074
02.02 932 001 852 568 798 622 34 217 29 286 4 931 63 503 7.7 6.6 1.1 −58 572
02.03 1 634 953 1 473 722 1 314 442 100 500 96 435 4 065 196 935 12.9 12.4 0.5 −192 870
03.01 249 303 229 448 204 067 23 278 12 977 10 301 36 255 19.4 10.8 8.6 −25 954
03.02 238 498 213 476 151 222 51 192 13 125 38 067 64 317 45.3 11.6 33.7 −26 250
04.01 256 742 236 876 226 429 7 314 4 189 3 125 11 503 5.9 3.4 2.5 −8 378
05.01 1 214 931 1 100 088 1 033 706 49 996 42 833 7 163 92 829 8.6 7.4 1.2 −85 666
05.02 337 887 305 551 289 364 12 205 11 035 1 170 23 240 7.6 6.9 0.7 −22 070
05.03 178 886 160 898 146 044 10 471 7 865 2 606 18 336 12.3 9.3 3.1 −15 730
05.04 820 838 739 193 682 071 39 917 32 900 7 017 72 817 10.2 8.4 1.8 −65 800
05.05 100 730 91 257 87 369 2 523 2 734 −211 5 257 5.3 5.7 −0.4 −5 468
06.01 284 478 261 255 218 236 35 557 20 501 15 056 56 058 26.1 15.0 11.0 −41 002
06.02 141 869 126 651 114 060 8 525 7 095 1 430 15 620 12.7 10.6 2.1 −14 190
07.01 363 135 323 012 303 891 12 556 22 117 −9 561 34 673 7.3 12.9 −5.6 −44 234
07.02 737 339 666 285 625 117 34 933 32 905 2 028 67 838 10.0 9.4 0.6 −65 810
08.01 847 021 777 112 735 809 26 491 26 700 −209 53 191 6.5 6.6 −0.1 −53 400
08.02 196 633 178 482 165 547 8 699 5 983 2 716 14 682 9.3 6.4 2.9 −11 966
08.03 111 346 101 500 95 303 4 207 6 746 −2 539 10 953 7.9 12.7 −4.8 −13 492
08.04 1 328 246 1 191 676 1 126 568 37 659 64 728 −27 069 102 387 6.0 10.3 −4.3 −129 456
Fuente: Estimaciones del CONAPO.

Migración intrametropolitana

Se utiliza la paquetería survey para poder trabajar con la muestra del cuestionario ampliado, en la cual se selecciona a la población de 5 años y más.

options(survey.lonely.psu = "adjust")

MC <- mydata %>%
       select(CVE_ENT, CVE_MUN, RES05EDO_C, CVE_MUN_RES, CVE_ZM, CVE_ZM_RES, M, EDAD, FACTOR, ESTRATO, UPM) %>%
        # Se genera una indicadora de zm 
        mutate(I_ZM_2020 = ifelse(is.na(.$CVE_ZM), '0', '1'),
               I_RES5A_ZM_2020 = ifelse(is.na(.$CVE_ZM_RES), '0', '1')) %>%
        # Se clasifican a los migrantes internos 
        mutate(I_ZM = case_when(.$CVE_MUN == .$CVE_MUN_RES ~ 'Pertenecen a la Zona Metropolitana', #Residentes
                                .$CVE_MUN != .$CVE_MUN_RES & .$I_ZM_2020 %in% '1' & .$I_RES5A_ZM_2020 %in% '1' & .$CVE_ZM == .$CVE_ZM_RES ~ "Pertenecen a la Zona Metropolitana", #Migrantes que residen en la misma zona metropolitana
                                .$CVE_MUN != .$CVE_MUN_RES & .$I_ZM_2020 %in% '1' & .$I_RES5A_ZM_2020 %in% '1' & .$CVE_ZM != .$CVE_ZM_RES ~ 'No pertenecen a la Zona Metropolitana', #Migrantes que residen en otra zona metropolitana
                                .$CVE_MUN != .$CVE_MUN_RES & .$I_ZM_2020 %in% '1' & .$I_RES5A_ZM_2020 %in% '0' ~ 'No pertenecen a la Zona Metropolitana', #Migrantes que residian fuera de la zona metropolitana
                                .$CVE_MUN != .$CVE_MUN_RES & .$I_ZM_2020 %in% '0' & .$I_RES5A_ZM_2020 %in% '1' ~ 'No pertenecen a la Zona Metropolitana', #Migrantes que residian dentro de una zona metropolitana
                                .$CVE_MUN != .$CVE_MUN_RES & .$I_ZM_2020 %in% '0' & .$I_RES5A_ZM_2020 %in% '0' ~ 'No pertenecen a la Zona Metropolitana' #Migrantes que no residen en la zona metropolitana
                                )) %>%
         filter(EDAD >= 5 & EDAD <= 130) %>%
          filter(CVE_MUN_RES %in% municipios & .$I_ZM %in% "Pertenecen a la Zona Metropolitana") %>%
           svydesign(data = ., id = ~ UPM, strata = ~ESTRATO, weight = ~FACTOR, nest = T)

saveRDS(MC, file = paste0(here::here(), "/Output/Municipio/06_Zonas Metropolitanas/2010/01_Migracion reciente/Base 2020/MC_intrametropolitana_Base2020.RDS"))

Indicadores

Se realizan cálculos generales de migración:

  • Residentes

  • Inmigrantes

  • Emigrantes

  • % Inmigrantes

  • % Emigrante

  • Migración bruta

  • Migración Neta

  • % Tasa de migración bruta

  • % Tasa de migración neta

Se trabaja con la matriz cuadrada, la cual de esta manera no se satura la computadora.

################################################################################
############################ Población total ###################################
Pob.Total <- mydata %>%
              as.data.frame() %>%
               group_by(CVE_ZM) %>%
                summarise(Pob.Total = sum(FACTOR)) 

################################################################################
###################### Población de 5 años y más ###############################
Pob.5ymas <- mydata %>%
              as.data.frame() %>%
               mutate(EDAD = as.numeric(.$EDAD)) %>%
                subset(EDAD >= 5 & EDAD <=130) %>%
                 group_by(CVE_ZM) %>%
                  summarise(Pob.5ymas = sum(FACTOR)) 

################################################################################
########################### Residentes #########################################
MR <- readRDS(paste0(here::here(), "/Output/Municipio/06_Zonas Metropolitanas/2010/01_Migracion reciente/Base 2020/Matrices de MR5a a nivel intramunicipal por ZM2010_Base2020.RDS"))

Residentes <- lapply(1:length(zm), function(x){
                                     MR[[x]] %>% 
                                      as.data.frame() %>%
                                       melt(., id.vars =  "CVE_MUN", variable.name = "CVE_MUN_RES") %>%
                                        mutate_at(vars(3), as.numeric) %>%
                                         filter(CVE_MUN == CVE_MUN_RES)  %>%
                                          summarize(Residentes =  sum(value, na.rm = TRUE)) %>% 
                                           mutate(CVE_ZM = !!paste0(zm[x])) 
})

Residentes <- do.call(rbind.data.frame, Residentes)

################################################################################
############################### Inmigrantes ####################################
Inmigrantes <- lapply(1:length(zm), function(x){
                                      MR[[x]] %>% 
                                       as.data.frame() %>%
                                        melt(., id.vars =  "CVE_MUN", variable.name = "CVE_MUN_RES") %>%
                                         mutate_at(vars(3), as.numeric) %>%
                                          filter(CVE_MUN != CVE_MUN_RES)  %>%
                                           summarize(Inmigrantes =  sum(value, na.rm = TRUE)) %>% 
                                            mutate(CVE_ZM = !!paste0(zm[x])) 
})

Inmigrantes <- do.call(rbind.data.frame, Inmigrantes)

################################################################################
############################### Emigrantes #####################################
Emigrantes <- lapply(1:length(zm), function(x){
                                    MR[[x]] %>% 
                                     tibble::column_to_rownames(var = "CVE_MUN") %>%
                                      t() %>%
                                       as.data.frame() %>%
                                        tibble::rownames_to_column(var = "CVE_MUN") %>%
                                         melt(., id.vars =  "CVE_MUN", variable.name = "CVE_MUN_RES") %>%
                                          mutate_at(vars(3), as.numeric) %>%
                                           filter(CVE_MUN != CVE_MUN_RES)  %>%
                                            summarize(Emigrantes=  sum(value, na.rm = TRUE)) %>% 
                                             mutate(CVE_ZM = !!paste0(zm[x])) 
})

Emigrantes <- do.call(rbind.data.frame, Emigrantes)

tabla <- Pob.Total %>%
          left_join(., Pob.5ymas, by = c("CVE_ZM")) %>%
          left_join(., Residentes, by = c("CVE_ZM")) %>%
          left_join(., Inmigrantes, by = c("CVE_ZM")) %>%
          left_join(., Emigrantes, by = c("CVE_ZM")) %>%
           mutate(Mig.Neta = .$Inmigrantes - .$Emigrantes,
                  Mig.Bruta = .$Inmigrantes + .$Emigrantes, 
                  Tasa.Inmig = ((.$Inmigrantes/ 5) /((.$Pob.Total + .$Pob.5ymas) / 2)) * 1000,
                  Tasa.Emig = ((.$Emigrantes/ 5) /((.$Pob.Total + .$Pob.5ymas) / 2)) * 1000,
                  Tasa.Mig = Tasa.Inmig - Tasa.Emig, 
                  Eficacia = Mig.Neta - Mig.Bruta)

write.xlsx(tabla, file = paste0(here::here(), "/Output/Municipio/06_Zonas Metropolitanas/2010/01_Migracion reciente/Base 2020/Indicadores de MR5a por ZM 2010 (Intrametropolitano) 2010_Base2020.xlsx"), overwrite = TRUE)
save(tabla, file = paste0(here::here(), "/Output/Municipio/06_Zonas Metropolitanas/2010/01_Migracion reciente/Base 2020/Indicadores de MR5a por ZM 2010 (Intrametropolitano) 2010_Base2020.RData"))
Indicadores de migración reciente (Nivel intrametropolitano)
Zonas Metropolitanas
CVE_ZM Pob.Total Pob.5ymas Residentes Inmigrantes Emigrantes Mig.Neta Mig.Bruta Tasa.Inmig Tasa.Emig Tasa.Mig Eficacia
01.01 930 969 837 849 767 103 6 659 6 659 0 13 318 1.506 1.506 0.0 −13 318
02.01 460 793 419 052 367 600 0 0 0 0 0.000 0.000 0.0 0
02.02 932 001 852 568 798 622 0 0 0 0 0.000 0.000 0.0 0
02.03 1 634 953 1 473 722 1 314 442 5 334 5 334 0 10 668 0.686 0.686 0.0 −10 668
03.01 249 303 229 448 204 067 0 0 0 0 0.000 0.000 0.0 0
03.02 238 498 213 476 151 222 0 0 0 0 0.000 0.000 0.0 0
04.01 256 742 236 876 226 429 0 0 0 0 0.000 0.000 0.0 0
05.01 1 214 931 1 100 088 1 033 706 15 454 15 454 0 30 908 2.670 2.670 0.0 −30 908
05.02 337 887 305 551 289 364 3 204 3 204 0 6 408 1.992 1.992 0.0 −6 408
05.03 178 886 160 898 146 044 987 987 0 1 974 1.162 1.162 0.0 −1 974
05.04 820 838 739 193 682 071 11 482 11 482 0 22 964 2.944 2.944 0.0 −22 964
05.05 100 730 91 257 87 369 216 216 0 432 0.450 0.450 0.0 −432
06.01 284 478 261 255 218 236 9 723 9 723 0 19 446 7.127 7.127 0.0 −19 446
06.02 141 869 126 651 114 060 539 539 0 1 078 0.803 0.803 0.0 −1 078
07.01 363 135 323 012 303 891 2 822 2 822 0 5 644 1.645 1.645 0.0 −5 644
07.02 737 339 666 285 625 117 5 444 5 444 0 10 888 1.551 1.551 0.0 −10 888
08.01 847 021 777 112 735 809 915 915 0 1 830 0.225 0.225 0.0 −1 830
08.02 196 633 178 482 165 547 775 775 0 1 550 0.826 0.826 0.0 −1 550
08.03 111 346 101 500 95 303 22 22 0 44 0.041 0.041 0.0 −44
08.04 1 328 246 1 191 676 1 126 568 0 0 0 0 0.000 0.000 0.0 0
Fuente: Estimaciones del CONAPO.

Migración intermetropolitana

Se utiliza la paquetería survey para poder trabajar con la muestra del cuestionario ampliado, en la cual se selecciona a la población de 5 años y más.

options(survey.lonely.psu = "adjust")

MC <- mydata %>%
       select(CVE_ENT, CVE_MUN, RES05EDO_C, CVE_MUN_RES, CVE_ZM, CVE_ZM_RES, M, EDAD, FACTOR, ESTRATO, UPM) %>%
        # Se genera una indicadora de zm 
        mutate(I_ZM_2020 = ifelse(is.na(.$CVE_ZM), '0', '1'),
               I_RES5A_ZM_2020 = ifelse(is.na(.$CVE_ZM_RES), '0', '1')) %>%
        # Se clasifican a los migrantes internos 
        mutate(I_ZM = case_when(.$CVE_MUN == .$CVE_MUN_RES ~ 'Pertenecen a la Zona Metropolitana', #Residentes
                                .$CVE_MUN != .$CVE_MUN_RES & .$I_ZM_2020 %in% '1' & .$I_RES5A_ZM_2020 %in% '1' & .$CVE_ZM == .$CVE_ZM_RES ~ "Pertenecen a la Zona Metropolitana", #Migrantes que residen en la misma zona metropolitana
                                .$CVE_MUN != .$CVE_MUN_RES & .$I_ZM_2020 %in% '1' & .$I_RES5A_ZM_2020 %in% '1' & .$CVE_ZM != .$CVE_ZM_RES ~ 'No pertenecen a la Zona Metropolitana', #Migrantes que residen en otra zona metropolitana
                                .$CVE_MUN != .$CVE_MUN_RES & .$I_ZM_2020 %in% '1' & .$I_RES5A_ZM_2020 %in% '0' ~ 'No pertenecen a la Zona Metropolitana', #Migrantes que residian fuera de la zona metropolitana
                                .$CVE_MUN != .$CVE_MUN_RES & .$I_ZM_2020 %in% '0' & .$I_RES5A_ZM_2020 %in% '1' ~ 'No pertenecen a la Zona Metropolitana', #Migrantes que residian dentro de una zona metropolitana
                                .$CVE_MUN != .$CVE_MUN_RES & .$I_ZM_2020 %in% '0' & .$I_RES5A_ZM_2020 %in% '0' ~ 'No pertenecen a la Zona Metropolitana' #Migrantes que no residen en la zona metropolitana
                                )) %>%
         filter(EDAD >= 5 & EDAD <= 130) %>%
          filter(CVE_MUN_RES %in% municipios & .$I_ZM %in% "No pertenecen a la Zona Metropolitana") %>%
           svydesign(data = ., id = ~ UPM, strata = ~ESTRATO, weight = ~FACTOR, nest = T)

saveRDS(MC, file = paste0(here::here(), "/Output/Municipio/06_Zonas Metropolitanas/2010/01_Migracion reciente/Base 2020/MC_intermetropolitana_Base2020.RDS"))

Indicadores

Se realizan cálculos generales de migración:

  • Residentes

  • Inmigrantes

  • Emigrantes

  • % Inmigrantes

  • % Emigrante

  • Migración bruta

  • Migración Neta

  • % Tasa de migración bruta

  • % Tasa de migración neta

Se trabaja con la matriz cuadrada, la cual de esta manera no se satura la computadora.

################################################################################
############################ Población total ###################################
Pob.Total <- mydata %>%
              as.data.frame() %>%
               group_by(CVE_ZM) %>%
                summarise(Pob.Total = sum(FACTOR)) 

################################################################################
###################### Población de 5 años y más ###############################
Pob.5ymas <- mydata %>%
              as.data.frame() %>%
               mutate(EDAD = as.numeric(.$EDAD)) %>%
                subset(EDAD >= 5 & EDAD <=130) %>%
                 group_by(CVE_ZM) %>%
                  summarise(Pob.5ymas = sum(FACTOR)) 

################################################################################
########################### Residentes #########################################
load(file = paste0(here::here(), "/Output/Municipio/06_Zonas Metropolitanas/2010/01_Migracion reciente/Base 2020/Matriz de migracion reciente a nivel intermunicipal 2010_Base2020.RData"))

ZM <- lapply(1:length(zm), function(x){
                    ZM_2020 %>% 
                     select(CVE_ZM, CVE_MUN, NOM_MUN) %>%
                      filter(CVE_ZM %in% zm[x])  %>% 
                      pull(CVE_MUN)
})

Residentes <- lapply(1:length(zm), function(x){
                                     Migrantes %>% 
                                      as.data.frame() %>%
                                       tibble::rownames_to_column(var = "CVE_MUN") %>%
                                        melt(., id.vars =  "CVE_MUN", variable.name = "CVE_MUN_RES") %>%
                                         mutate_at(vars(3), as.numeric) %>%
                                          filter(CVE_MUN == CVE_MUN_RES)  %>%
                                           filter(CVE_MUN %in% ZM[[x]]) %>%
                                            summarize(Residentes =  sum(value, na.rm = TRUE)) %>% 
                                             mutate(CVE_ZM = !!paste0(zm[x])) 
})

Residentes <- do.call(rbind.data.frame, Residentes)

################################################################################
############################### Inmigrantes ####################################
Inmigrantes <- lapply(1:length(zm), function(x){
                                     Migrantes %>% 
                                      as.data.frame() %>%
                                       tibble::rownames_to_column(var = "CVE_MUN") %>%
                                        melt(., id.vars =  "CVE_MUN", variable.name = "CVE_MUN_RES") %>%
                                         mutate_at(vars(3), as.numeric) %>%
                                          filter(CVE_MUN != CVE_MUN_RES)  %>%
                                           filter(CVE_MUN %in% ZM[[x]]) %>%
                                            summarize(Inmigrantes =  sum(value, na.rm = TRUE)) %>% 
                                             mutate(CVE_ZM = !!paste0(zm[x])) 
})

Inmigrantes <- do.call(rbind.data.frame, Inmigrantes)

################################################################################
############################### Emigrantes #####################################
Emigrantes <- lapply(1:length(zm), function(x){
                                     Migrantes %>% 
                                      t() %>%
                                       as.data.frame() %>%
                                        tibble::rownames_to_column(var = "CVE_MUN") %>%
                                         melt(., id.vars =  "CVE_MUN", variable.name = "CVE_MUN_RES") %>%
                                          mutate_at(vars(3), as.numeric) %>%
                                           filter(CVE_MUN != CVE_MUN_RES)  %>%
                                           filter(CVE_MUN %in% ZM[[x]]) %>%
                                            summarize(Emigrantes =  sum(value, na.rm = TRUE)) %>% 
                                             mutate(CVE_ZM = !!paste0(zm[x])) 
})

Emigrantes <- do.call(rbind.data.frame, Emigrantes)

tabla <- Pob.Total %>%
          left_join(., Pob.5ymas, by = c("CVE_ZM")) %>%
          left_join(., Residentes, by = c("CVE_ZM")) %>%
          left_join(., Inmigrantes, by = c("CVE_ZM")) %>%
          left_join(., Emigrantes, by = c("CVE_ZM")) %>%
           mutate(Mig.Neta = .$Inmigrantes - .$Emigrantes,
                  Mig.Bruta = .$Inmigrantes + .$Emigrantes, 
                  Tasa.Inmig = ((.$Inmigrantes/ 5) /((.$Pob.Total + .$Pob.5ymas) / 2)) * 1000,
                  Tasa.Emig = ((.$Emigrantes/ 5) /((.$Pob.Total + .$Pob.5ymas) / 2)) * 1000,
                  Tasa.Mig = Tasa.Inmig - Tasa.Emig, 
                  Eficacia = Mig.Neta - Mig.Bruta)

write.xlsx(tabla, file = paste0(here::here(), "/Output/Municipio/06_Zonas Metropolitanas/2010/01_Migracion reciente/Base 2020/Indicadores de MR5a por ZM 2010 (Intermetropolitano) 2010_Base2020.xlsx"), overwrite = TRUE)
save(tabla, file = paste0(here::here(), "/Output/Municipio/06_Zonas Metropolitanas/2010/01_Migracion reciente/Base 2020/Indicadores de MR5a por ZM 2010 (Intermetropolitano) 2010_Base2020.RData"))
Indicadores de migración reciente (Nivel intermetropolitano)
Zonas Metropolitanas
CVE_ZM Pob.Total Pob.5ymas Residentes Inmigrantes Emigrantes Mig.Neta Mig.Bruta Tasa.Inmig Tasa.Emig Tasa.Mig Eficacia
01.01 930 969 837 849 0 45 132 24 190 20 942 69 322 10.2 5.5 4.7 −48 380
02.01 460 793 419 052 0 37 646 20 037 17 609 57 683 17.1 9.1 8.0 −40 074
02.02 932 001 852 568 0 34 217 29 286 4 931 63 503 7.7 6.6 1.1 −58 572
02.03 1 634 953 1 473 722 0 95 166 91 101 4 065 186 267 12.2 11.7 0.5 −182 202
03.01 249 303 229 448 0 23 278 12 977 10 301 36 255 19.4 10.8 8.6 −25 954
03.02 238 498 213 476 0 51 192 13 125 38 067 64 317 45.3 11.6 33.7 −26 250
04.01 256 742 236 876 0 7 314 4 189 3 125 11 503 5.9 3.4 2.5 −8 378
05.01 1 214 931 1 100 088 0 34 542 27 379 7 163 61 921 6.0 4.7 1.2 −54 758
05.02 337 887 305 551 0 9 001 7 831 1 170 16 832 5.6 4.9 0.7 −15 662
05.03 178 886 160 898 0 9 484 6 878 2 606 16 362 11.2 8.1 3.1 −13 756
05.04 820 838 739 193 0 28 435 21 418 7 017 49 853 7.3 5.5 1.8 −42 836
05.05 100 730 91 257 0 2 307 2 518 −211 4 825 4.8 5.2 −0.4 −5 036
06.01 284 478 261 255 0 25 834 10 778 15 056 36 612 18.9 7.9 11.0 −21 556
06.02 141 869 126 651 0 7 986 6 556 1 430 14 542 11.9 9.8 2.1 −13 112
07.01 363 135 323 012 0 9 734 19 295 −9 561 29 029 5.7 11.2 −5.6 −38 590
07.02 737 339 666 285 0 29 489 27 461 2 028 56 950 8.4 7.8 0.6 −54 922
08.01 847 021 777 112 0 25 576 25 785 −209 51 361 6.3 6.4 −0.1 −51 570
08.02 196 633 178 482 0 7 924 5 208 2 716 13 132 8.4 5.6 2.9 −10 416
08.03 111 346 101 500 0 4 185 6 724 −2 539 10 909 7.9 12.6 −4.8 −13 448
08.04 1 328 246 1 191 676 0 37 659 64 728 −27 069 102 387 6.0 10.3 −4.3 −129 456
Fuente: Estimaciones del CONAPO.

Referencias

Librerias que se usaron en el documento

package loadedversion source
Cairo 1.6-1 CRAN (R 4.3.1)
chorddiag 0.1.3 Github ()
circlize 0.4.15 CRAN (R 4.3.1)
doMC 1.3.5 R-Forge (R 4.3.1)
dplyr 1.1.3 CRAN (R 4.3.2)
expss 0.11.6 CRAN (R 4.3.1)
foreach 1.5.2 CRAN (R 4.3.1)
ggalluvial 0.12.5 CRAN (R 4.3.1)
ggplot2 3.4.3 CRAN (R 4.3.1)
ggpubr 0.6.0 CRAN (R 4.3.1)
ggrepel 0.9.3 CRAN (R 4.3.1)
ggsankey 0.0.99999 Github ()
gt 0.10.0 CRAN (R 4.3.1)
haven 2.5.3 CRAN (R 4.3.1)
Hmisc 5.1-0 CRAN (R 4.3.1)
iterators 1.0.14 CRAN (R 4.3.1)
janitor 2.2.0 CRAN (R 4.3.1)
kableExtra 1.3.4 CRAN (R 4.3.1)
knitr 1.45 CRAN (R 4.3.2)
maditr 0.8.3 CRAN (R 4.3.1)
Matrix 1.6-1.1 CRAN (R 4.3.1)
network 1.18.1 CRAN (R 4.3.1)
openxlsx 4.2.5.2 CRAN (R 4.3.1)
reshape2 1.4.4 CRAN (R 4.3.1)
sjlabelled 1.2.0 CRAN (R 4.3.1)
sna 2.7-1 CRAN (R 4.3.1)
srvyr 1.2.0 CRAN (R 4.3.1)
statnet.common 4.9.0 CRAN (R 4.3.1)
stringr 1.5.0 CRAN (R 4.3.1)
survey 4.2 Github ()
survival 3.5-5 CRAN (R 4.3.1)
tibble 3.2.1 CRAN (R 4.3.1)
tidyr 1.3.1 CRAN (R 4.3.3)

Creative Commons Licence
This work by Diana Villasana Ocampo is licensed under a Creative Commons Attribution 4.0 International License.